package com.aaa.gs.controller;

import com.aaa.common.entity.Order;
import com.aaa.gs.po.Product;
import com.aaa.gs.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("product")
public class ProductController {
   @Autowired
    private ProductService productService;
    /**
     * 列表
     * @return
     */
    @GetMapping("selectAll")
    public Map selectAll(){
        Map map=new HashMap();
        List<Product> products= productService.selectAll();
        List<Order> orders=productService.selectOrders();
        map.put("product",products);
        map.put("orders",orders);
        return map;
    }
    /**
     * 根据编号查询
     * @param id
     * @return
     */
    @GetMapping("selectByPrimaryKey")
    public Product selectByPrimaryKey(Long id){
        return productService.selectByPrimaryKey(id);
    }
}
